d<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>_覆盖区域管理</title>
</head>
<body>
<section class="content">
<script src="/wms/static/js/Ctry/select.js" type="text/javascript"></script>
<script>
	function addArea(){
		if($("#SelectProvince").val() == null || $("#SelectProvince").val() == '省份') {
			alert("请选择省份");
			return;
		}
		$('#queryForm').submit();	
	}

	function deleteArea(id,code) {
    	if(confirm("确认删除？")) {
    	  $.ajax({
			    type : 'post',
				url : '${ctx}/v2/customers/deleteCoverageArea',
				data : {
				  "id":id
				},
				success : function(data) {
				  	if(data=='success') {
				  	  	location.reload();
				  	} else {
				  		alert("修改失败");
				  	}
				},
				error : function(data) {
				  	alert("网络繁忙，请稍后重试...","温馨提示");
				}
			});
    	}
  	}
</script>
		<div class="row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
			<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">添加覆盖区</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">	
					<form class="form-search" id="queryForm" action="${ctx}/v2/customers/addCoverageArea" method="post">
						<input type="hidden" name="customerCode" value="${customer.customerCode}"/>
						<div class="form-group row">
							<div class="input-group col-sm-4">
								<span class="input-group-text"> 仓库：  </span>
								<font>${warehouse.groupName }</font>
								<input type="hidden" name="warehouseCode" value="${warehouse.groupCode }"/>
							</div>
						</div>
						<div class="form-group row">
							<div class="input-group col-sm-4">
								<span class="input-group-text"> 省：  </span>
								<select class="form-control" id="SelectProvince" name="SelectProvince"></select>
							</div>
						</div>
						<div class="form-group row">
							<div class="input-group col-sm-4">
								<span class="input-group-text"> 市：  </span>
								<select class="form-control" id="SelectCity" name="SelectCity">
								</select>
							</div>
						</div>
					</form>
					<div class="input-group col-sm-4">
						<button class="btn btn-info" onclick="addArea()">设为覆盖区</button>
					</div>
				</div>
			</div>
		</div>
		</s>
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">已设置的覆盖区</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
			    <th>仓库</th>
			    <th>省</th>
			    <th>市</th>
			    <th>创建时间</th>
			    <th>创建人</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
			<c:forEach items="${coverageAreas}" var="area">
				<tr>
					<th>${area.warehouseCode }</th>
					<th>${area.province }</th>
					<th>${area.city }</th>
					<th>${area.createTime }</th>
					<th>${area.creatorName }</th>
					<th><button class="btn btn-danger" onclick="deleteArea('${area.id}','${area.warehouseCode }')">删除</button></th>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
	
</section>	
</body>
</html>
